import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import router from './router'
import axios from 'axios'
import  http from '@/utils/http.js'
import store from './store'
import dayjs from 'dayjs'
import VueI18n from 'vue-i18n'
import Cookies from "js-cookie";
import  vant  from 'vant';
import { download, downloadGet } from '@/utils/request'
Vue.use(VueI18n)
Vue.use(Cookies)
Vue.use(vant)
// router.beforeEach((to,from,next)=>{
//     if(localStorage.getItem("userId")){
//       next()
//     }else{
//       if(to.path=='/login' || to.path=='/register'){
//         next()
//       }
// else{
//         next('/login')
//       }
//     } 
// })

Vue.prototype.$dayjs=dayjs
const i18n=new VueI18n({
  locale:'language',
  messages:{
    language:{
      ...require("./utils/languages/language")
    }
  }
})

Vue.use(ElementUI)
Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.prototype.$http = http
// Vue.prototype.download = download
Vue.prototype.downloadGet = downloadGet
// 防抖
// Vue.directive('debounce', {
//   inserted(el, binding, vnode) {
//     let timer = {}
//     el.addEventListener('click', () => {
//       if (timer) {
//         clearTimeout(timer)
//       }
//       timer = setTimeout(() => {
//         binding.value()
//       },1000)  //设置时间为1s之后请求
//     })
//   }
// })

new Vue({
  router,
  store,
  i18n,
  render: h => h(App),
}).$mount('#app')
